<template>
    <div>
        <van-nav-bar title="详情页" left-text="返回" left-arrow @click-left="onClickLeft" />
        <div v-html="detailApidata.goods_introduce"></div>
        <van-action-bar>
            <van-action-bar-icon icon="chat-o" text="客服" dot />
            <van-action-bar-icon icon="cart-o" text="购物车" badge="5" />
            <van-action-bar-icon icon="shop-o" text="店铺" badge="12" />
            <van-action-bar-button type="warning" text="加入购物车" @click="jr" />
            <van-action-bar-button type="danger" text="立即购买" />
        </van-action-bar>
    </div>
</template>

<script setup>
import { detailApi } from '@/api/api';
import router from '@/router';
import { ref } from 'vue';
import { useRoute } from 'vue-router';
import { useCounterStore } from '@/stores/cart'
// 在组件内部的任何地方均可以访问变量 `store` ✨
const store = useCounterStore()
const onClickLeft = () => {
    router.push('/')
}
let rou = useRoute()
let detailApidata = ref([])
detailApi(rou.params.goods_id).then(res => {
    console.log(res);

    detailApidata.value = res.data.message
})
const jr = () => {
    store.piniaAddCart(detailApidata.value, rou.params.goods_id)
    router.push('/index/cart')
}
</script>

<style lang="scss" scoped></style>